//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_getranpointouterair.sqf"
#include "x_setup.sqf"

// get a random point at the borders of the current island for spawning air vehicles (no slope check, no is water check, etc)
// parameters:
// center position, left x, left y, width, height, angle (optional)
private ["_pos", "_centerx", "_centery", "_leftx", "_lefty", "_width", "_height", "_rside", "_px1", "_py1", "_radius", "_atan", "_x1", "_y1"];
_pos = GVAR(island_center);
_centerx = _pos select 0; _centery = _pos select 1;
_leftx = 250;_lefty = 250;
_width = (2 * (_pos select 0)) - 500;
_height = (2 * (_pos select 1)) - 500;
_rside = floor (random 4);
_px1 = switch (_rside) do {
	case 0: {_leftx + random _width};
	case 1: {_leftx + _width};
	case 2: {_leftx + random _width};
	case 3: {_leftx};
};
_py1 = switch (_rside) do {
	case 0: {_lefty + _height};
	case 1: {_lefty + random _height};
	case 2: {_lefty};
	case 3: {_lefty + random _height};
};
_radius = _pos distance [_px1,_py1,_pos select 2];
_atan = (_centerx - _px1) atan2 (_centery - _py1);
_x1 = _centerx - (_radius * sin _atan);
_y1 = _centery - (_radius * cos _atan);
[_x1, _y1, 300]